//
//  BaseMessageView.m
//  CoachsBook
//
//  Created by MaBookPro on 2022/8/20.
//

#import "BaseMessageView.h"

@implementation BaseMessageView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{
 
    UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 270)];
    backview.backgroundColor = [UIColor whiteColor];
    [self addSubview:backview];

    UIView *studentLine = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    studentLine.backgroundColor = rgba(22, 120, 255, 1);
    studentLine.layer.cornerRadius = 2;
    [backview addSubview:studentLine];
    UILabel *studentLab = [[UILabel alloc]initWithFrame:CGRectMake(studentLine.frame.size.width+studentLine.frame.origin.x+5, 15, 70, 15)];
    studentLab.text = @"基本信息";
    studentLab.textColor = [UIColor blackColor];
    studentLab.textAlignment = 0;
    studentLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [backview addSubview:studentLab];


    
    NSArray *myStudentLabArrs = @[@"姓名",@"电话",@"科目状态"];
    for (int i = 0; i < myStudentLabArrs.count; i++) {
        UIButton *studentBtn = [[UIButton alloc]initWithFrame: CGRectMake(0, studentLab.height+studentLab.y+i+45*i, APPwidth, 45)];
        studentBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        studentBtn.contentHorizontalAlignment = 1;
        [studentBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
        studentBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);
        [studentBtn setTitle:myStudentLabArrs[i] forState:0];
        [backview addSubview:studentBtn];
        
        
        UITextField *txtf = [[UITextField alloc]initWithFrame:CGRectMake(APPwidth/2-15, 10, APPwidth/2, 25)];
        txtf.textColor = rgba(153, 153, 153, 1);
        txtf.placeholder = @"请输入姓名";
        txtf.font = [UIFont systemFontOfSize:14];
        txtf.textAlignment = 2;
        [studentBtn addSubview:txtf];
            
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(15, studentBtn.height-1, APPwidth-30, 1)];
        line.backgroundColor = rgba(245, 245, 250, 1);
        [studentBtn addSubview:line];

        if (i == 1) {
            txtf.placeholder = @"请输入电话号码";
            txtf.keyboardType = UIKeyboardTypeNumberPad;
        }else if (i == 2) {
            txtf.hidden = YES;
            line.hidden = YES;
        }
        
    }
    
    NSArray *titleLabarr = @[@"咨询",@"科一",@"科二",@"科三",@"科四",@"拿本"];
    CGFloat btnW = (APPwidth-70)/4;
    CGFloat btnH = 35;
    for (int b = 0; b < titleLabarr.count; b++) {
        NSInteger row = b/4;
        NSInteger col = b%4;
        CGFloat btnX = 15 + (btnW + 15 ) * col;
        CGFloat btnY = 10 + (btnH + 20 ) * row;
        
        UIButton *titleBtn = [[UIButton alloc]initWithFrame: CGRectMake(btnX,btnY+studentLab.frame.size.height+studentLab.frame.origin.y+120, btnW, btnH)];
        [titleBtn setTitle:titleLabarr[b] forState:0];
        [titleBtn setBackgroundColor:rgba(245, 245, 250, 1)];
        titleBtn.layer.cornerRadius = 17.5;
        [titleBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
        titleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [backview addSubview:titleBtn];

    }
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(15, backview.height-1, APPwidth-30, 1)];
    line.backgroundColor = rgba(245, 245, 250, 1);
    [backview addSubview:line];
    //性别 + 驾照类型
    UIView *xbackview = [[UIView alloc]initWithFrame:CGRectMake(0, backview.height + backview.y, APPwidth, 340)];
    xbackview.backgroundColor = [UIColor whiteColor];
    [self addSubview:xbackview];


    
    UILabel *sexlab = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, APPwidth-30, 45)];
    sexlab.text = @"姓别";
    sexlab.textColor = rgba(51, 51, 51, 1);
    sexlab.textAlignment = 0;
    sexlab.font = [UIFont systemFontOfSize:14];
    [xbackview addSubview:sexlab];
   
    
    
    UIButton *manbtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth-140, 15, 60, 20)];
    [manbtn setTitle:@"  男" forState:0];
    [manbtn setImage:[UIImage imageNamed:@"choice"] forState:0];
    manbtn.titleLabel.textAlignment = 2;
    manbtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [manbtn setTitleColor:[UIColor blackColor] forState:0];
    [sexlab addSubview:manbtn];
    
    UIButton *womanbtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth-80, 15, 60, 20)];
    [womanbtn setTitle:@"  女" forState:0];
    [womanbtn setImage:[UIImage imageNamed:@"nochoice"] forState:0];
    womanbtn.titleLabel.textAlignment = 2;
    womanbtn.titleLabel.font = [UIFont systemFontOfSize:13];
    [womanbtn setTitleColor:[UIColor blackColor] forState:0];
    [sexlab addSubview:womanbtn];
    
    UIView *sline = [[UIView alloc]initWithFrame:CGRectMake(0, sexlab.height-1, APPwidth-30, 1)];
    sline.backgroundColor = rgba(245, 245, 250, 1);
    [sexlab addSubview:sline];
    
    UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(15,  sline.frame.size.height + sline.frame.origin.y+15, 100, 20)];
    typeLab.text = @"驾照类型";
    typeLab.textColor = rgba(51, 51, 51, 1);
    typeLab.textAlignment = 0;
    typeLab.font = [UIFont systemFontOfSize:14];
    [xbackview addSubview:typeLab];
    
    NSArray *jiazhaotypeArr = @[@"C1",
                                @"C2",
                                @"C3",
                                @"C4",
                                @"C5",
                                @"C6",
                                @"A1",
                                @"A2",
                                @"A3",
                                @"B1",
                                @"B2",
                                @"D",
                                @"E",
                                @"F"];
    CGFloat jzbtnW = (APPwidth-50)/4;
    CGFloat jzbtnH = 35;
    for (int j = 0; j < jiazhaotypeArr.count; j++) {
        NSInteger jzrow = j/4;
        NSInteger jzcol = j%4;
        CGFloat jzbtnX = 10 + (jzbtnW + 10 ) * jzcol;
        CGFloat jzbtnY = 10 + (jzbtnH + 10 ) * jzrow;
        
        UIButton *jztitleBtn = [[UIButton alloc]initWithFrame: CGRectMake(jzbtnX,jzbtnY+typeLab.frame.size.height+typeLab.frame.origin.y+10, jzbtnW, jzbtnH)];
        [jztitleBtn setTitle:jiazhaotypeArr[j] forState:0];
        [jztitleBtn setBackgroundColor:rgba(245, 245, 250, 1)];
        jztitleBtn.layer.cornerRadius = 17.5;
        [jztitleBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
        jztitleBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [xbackview addSubview:jztitleBtn];
    }
    
    
    UIView *addressLine = [[UIView alloc]initWithFrame:CGRectMake(15, xbackview.height-55, APPwidth-30, 1)];
    addressLine.backgroundColor = rgba(245, 245, 250, 1);
    [xbackview addSubview:addressLine];
    
    
    UILabel *addressLab = [[UILabel alloc]initWithFrame:CGRectMake(15, addressLine.height+addressLine.y, APPwidth-30, 45)];
    addressLab.text = @"地址";
    addressLab.textColor = rgba(51, 51, 51, 1);
    addressLab.textAlignment = 0;
    addressLab.font = [UIFont systemFontOfSize:14];
    [xbackview addSubview:addressLab];
   
    UIButton *choiceAddressBtn = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth-140, 15, 120, 20)];
    [choiceAddressBtn setImage:[UIImage imageNamed:@"arrowl"] forState:0];
    [choiceAddressBtn setTitle:@"请选择" forState:0];
    choiceAddressBtn.titleLabel.textAlignment = 0;
    choiceAddressBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [choiceAddressBtn setTitleColor:rgba(153, 153, 153, 1) forState:0];
    choiceAddressBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 60, 0, -40);
    [choiceAddressBtn.imageView setContentMode:UIViewContentModeScaleAspectFit];
    choiceAddressBtn.titleEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 10);
    [addressLab addSubview:choiceAddressBtn];
    
    UIView *addressBottomLine = [[UIView alloc]initWithFrame:CGRectMake(0, xbackview.height-10, APPwidth, 10)];
    addressBottomLine.backgroundColor = rgba(245, 245, 250, 1);
    [xbackview addSubview:addressBottomLine];
    
    
    //付款信息
    UIView *fkbackview = [[UIView alloc]initWithFrame:CGRectMake(0, xbackview.height+xbackview.y, APPwidth, 130)];
    fkbackview.backgroundColor = [UIColor whiteColor];
    fkbackview.userInteractionEnabled = YES;
    [self addSubview:fkbackview];
    
    
    UIView *fkLine = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    fkLine.backgroundColor = rgba(22, 120, 255, 1);
    fkLine.layer.cornerRadius = 2;
    [fkbackview addSubview:fkLine];
    UILabel *fkLab = [[UILabel alloc]initWithFrame:CGRectMake(fkLine.frame.size.width+fkLine.frame.origin.x+5, 15, 70, 15)];
    fkLab.text = @"付款信息";
    fkLab.textColor = [UIColor blackColor];
    fkLab.textAlignment = 0;
    fkLab.font = [UIFont systemFontOfSize:16 weight:bold];
    [fkbackview addSubview:fkLab];
    
    NSArray *fkLabArrs = @[@"报名费",@"已收款"];
    NSArray *txtLabArrs = @[@"请输入整数",@"请输入整数"];
    for (int k = 0; k < fkLabArrs.count; k++) {
        UIButton *fkBtn = [[UIButton alloc]initWithFrame: CGRectMake(0, fkLab.height+fkLab.y+k+45*k, APPwidth, 45)];
        fkBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        fkBtn.contentHorizontalAlignment = 1;
        fkBtn.userInteractionEnabled = YES;
        [fkBtn setTitleColor:rgba(51, 51, 51, 1) forState:0];
        fkBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 15, 0, 0);
        [fkBtn setTitle:fkLabArrs[k] forState:0];
        [fkbackview addSubview:fkBtn];
        
        
        UITextField *fktxtf = [[UITextField alloc]initWithFrame:CGRectMake(APPwidth/2-15, 10, APPwidth/2-30, 25)];
        fktxtf.textColor = rgba(153, 153, 153, 1);
        fktxtf.placeholder = txtLabArrs[k];
        fktxtf.keyboardType = UIKeyboardTypeNumberPad;
        fktxtf.font = [UIFont systemFontOfSize:14];
        fktxtf.textAlignment = 2;
        [fkBtn addSubview:fktxtf];
            
        UILabel *typeLab = [[UILabel alloc]initWithFrame:CGRectMake(APPwidth-40,  10, 20, 25)];
        typeLab.text = @"元";
        typeLab.textColor = rgba(51, 51, 51, 1);
        typeLab.textAlignment = 2;
        typeLab.font = [UIFont systemFontOfSize:14];
        [fkBtn addSubview:typeLab];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(15, fkBtn.height-1, APPwidth-30, 1)];
        line.backgroundColor = rgba(245, 245, 250, 1);
        [fkBtn addSubview:line];

        if (k == 1) {
            line.hidden = YES;
        }
    }
    UIView *fkBottomLine = [[UIView alloc]initWithFrame:CGRectMake(0, fkbackview.height-10, APPwidth, 10)];
    fkBottomLine.backgroundColor = rgba(245, 245, 250, 1);
    [fkbackview addSubview:fkBottomLine];
    
}

@end
